﻿using AOT;
using System;
using System.Runtime.InteropServices;
using UnityEngine;

namespace Car.NavMesh
{
    public class CarLog
    {
        public static void RegisterLogCallback()
        {
            CarNavMeshInterface.SetLogCallback(LogMessage);
        }

        public static void RegisterLogWarningCallback()
        {
            CarNavMeshInterface.SetLogWarningCallback(LogWarning);
        }

        public static void RegisterLogErrorCallback()
        {
            CarNavMeshInterface.SetLogErrorCallback(LogError);
        }

        [MonoPInvokeCallback(typeof(Action<IntPtr>))]
        public static void LogMessage(IntPtr messagePtr)
        {
            string message = Marshal.PtrToStringUni(messagePtr);
            Debug.Log(message);
        }

        [MonoPInvokeCallback(typeof(Action<IntPtr>))]
        public static void LogWarning(IntPtr messagePtr)
        {
            string message = Marshal.PtrToStringUni(messagePtr);
            Debug.LogWarning(message);
        }

        [MonoPInvokeCallback(typeof(Action<IntPtr>))]
        public static void LogError(IntPtr messagePtr)
        {
            string message = Marshal.PtrToStringUni(messagePtr);
            Debug.LogError(message);
        }
    }
}


